package lei.k_java字符串处理;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.RandomStringUtils;

import java.util.Arrays;
import java.util.UUID;

/**
 * @className: StringUtilsExample
 * @author: xl
 * @date: 2025/3/3 20:28
 * @Version: 1.0
 * @description:
 */

public class StringUtilsExample {
    public static void main(String[] args) {
        String str="hello world";

        int str1=StringUtils.length(str);
        System.out.println(str1);

        String str2=StringUtils.replace(str,"h","H");
        System.out.println(str2);

        int a=StringUtils.indexOf(str,"w");
        int b=StringUtils.indexOf(str,"d");

        String str3=StringUtils.substring(str,a,b+1);
        System.out.println(str3);


        String randomNumeric = RandomStringUtils.randomNumeric(6); // 6位数字
        String randomAlphabetic = RandomStringUtils.randomAlphabetic(5); // 5位字母

        System.out.println("随机数字: " + randomNumeric);
        System.out.println("随机字母: " + randomAlphabetic);

        System.out.println(RandomStringUtils.random(3, "avddfdfdfdfdfdf"));

        System.out.println(UUID.randomUUID());


    }
}

